package com.zry.yard.ui.activity

import android.view.View
import com.zry.yard.R
import com.zry.yard.databinding.ActivityBatchListBinding
import com.zry.yard.presenter.BatchListPresenter
import com.zry.yard.ui.base.BaseActivity
import kotlinx.android.synthetic.main.activity_batch_list.*
import kotlinx.android.synthetic.main.common_title.*

class BatchListActivity : BaseActivity() {
    private var batchListBinding: ActivityBatchListBinding? = null
    private var batchListPresenter: BatchListPresenter? = null
    var title = ""
    override fun getLayoutId(): Int {
        return R.layout.activity_batch_list
    }

    override fun initData() {
        title = intent.getStringExtra("title")



        commonLeftLinearLayout.setOnClickListener { finish() }

        batchListBinding = viewDataBinding as ActivityBatchListBinding
        batchListPresenter = BatchListPresenter(this)
        batchListBinding?.handlerClick = batchListPresenter

        batchListPresenter?.initRecycler()
        batchListPresenter?.getBatchList()

        when (title) {
            "批次创建" -> {
                titleCenterText.text = "批次列表"
            }
            "溯源录入" -> {
                titleCenterText.text = "溯源列表"
                createNewBatchLinear.visibility = View.GONE
            }
        }
    }

    override fun onResume() {
        super.onResume()
        batchListPresenter?.getBatchList()
    }
}
